﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;
using WorldSimulator.PhysicEngine;
using WorldSimulator.PhysicsEngine;

namespace WorldSimulatorWPF.ViewModel
{
	/// <summary>
	/// Contains all static viewmodels
	/// </summary>
	public class ViewModelLocator
	{
		static ViewModelLocator()
		{
			ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

			//if (ViewModelBase.IsInDesignModeStatic)
			//{
			//	SimpleIoc.Default.Register<IDataService, Design.DesignDataService>();
			//}
			//else
			//{
			//	SimpleIoc.Default.Register<IDataService, DataService>();
			//}

			SimpleIoc.Default.Register<IPhysicsEngine>(() => new MyPhysicsEngine());
			SimpleIoc.Default.Register<MainWindowViewModel>();
		}

		/// <summary>
		/// Gets the MainWindowViewModel
		/// </summary>
		public MainWindowViewModel Main
		{
			get
			{
				return ServiceLocator.Current.GetInstance<MainWindowViewModel>();
			}
		}

		/// <summary>
		/// Cleans up all the resources.
		/// </summary>
		public static void Cleanup()
		{
			ServiceLocator.Current.GetInstance<MainWindowViewModel>().Cleanup();
		}
	}
}